package com.wechatapp.mengyao.poetry.controller;

import com.wechatapp.mengyao.poetry.core.PageResult;
import com.wechatapp.mengyao.poetry.core.RestResponse;
import com.wechatapp.mengyao.poetry.service.AlbumService;
import com.wechatapp.mengyao.poetry.service.MediaService;
import com.wechatapp.mengyao.poetry.vo.AlbumView;
import com.wechatapp.mengyao.poetry.vo.MediaView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author yanghuaxu
 * @date 2025/7/5 16:46
 */
@RestController
@RequestMapping("/api/v1/media")
public class MediaController {

    @Autowired
    private MediaService mediaService;

    @GetMapping("/page")
    public RestResponse<PageResult<MediaView>> getMediaList(@RequestParam Map<String, String> map) {

        return RestResponse.ok(mediaService.getMediaListByAlbumId(map));
    }

    @GetMapping("/position")
    public RestResponse<PageResult<MediaView>> getMediaPageById(@RequestParam Map<String, String> map) {

        return RestResponse.ok(mediaService.getMediaPageById(map));
    }


    @GetMapping("/{id}")
    public RestResponse<MediaView> getMediaById(@PathVariable Long id) {

        return RestResponse.ok(mediaService.getById(id));
    }
}
